import { get } from '@/api/axios'
import { type BiuJsonResult } from '@/api/biu-json-result'

export const urlPrefix: string = '/api/operator'

export interface OperatorItem {
  id: string
  name: string
  className: string
  type: string
  parameters: Array<any>
}

export interface OperatorItemGroupByPackage {
  id: string
  name: string
  tag: string
  functions: Array<OperatorItem>
}

export function doQueryOperatorListGroupByPackage(type: string, keyword?: string) {
  const url =
    `${urlPrefix}/list-group-by-package?type=${type}` +
    (keyword ? '&keyword=' + encodeURIComponent(keyword) : '')
  return get<BiuJsonResult<Array<OperatorItemGroupByPackage>>>(url)
}
